package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.prefecture.PrefectureBO;
import com.micro.modual.model.bo.prefecturegoods.PrefectureGoodsBO;
import com.micro.modual.model.bo.prefecturegoods.PrefectureGoodsListBO;
import com.micro.modual.model.bo.prefecturegoods.PrefectureGoodsStatusBO;
import com.micro.modual.model.dto.goodssku.GoodsSkuListDTO;
import com.micro.modual.model.dto.prefecture.PrefectureDetailDTO;
import com.micro.modual.model.dto.prefecture.PrefectureListDTO;
import com.micro.modual.model.dto.prefecture.PrefectureStatusBO;
import com.micro.modual.model.dto.prefecturegoods.PrefectureGoodsListDTO;
import com.micro.modual.service.PrefectureGoodsService;
import com.micro.modual.service.PrefectureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <h1>专区表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "专区管理",tags = "专区管理")
@RestController
@RequestMapping(value = "prefecture")
public class PrefectureController {

    @Autowired
    private PrefectureService prefectureService;

    @Autowired
    private PrefectureGoodsService prefectureGoodsService;

    /**
     * <h2>查找专区表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<PrefectureListDTO> {@link PrefectureListDTO}s  专区表 列表返回对象
     */
    @ApiOperation(value = "查询专区表列表" ,notes = "查询专区表列表")
    @GetMapping(value = "/findPrefectureList")
    public RespJsonPageData<PrefectureListDTO> findPrefectureList(@RequestParam  Map<String,Object> params){
        return prefectureService.findList(params,PrefectureListDTO.class);
    }

    /**
     * <h2>根据主键编号查看专区表详情</h2>
     * @param id  专区表 主键编号
     * @return {@link PrefectureDetailDTO}  专区表 详情
     */
    @ApiOperation(value = "查询专区表详情",notes = "根据主键编号，查询专区表详情")
    @GetMapping(value = "/findPrefectureDetail/{id}")
    public RespJsonData<PrefectureDetailDTO> findPrefectureDetail(@PathVariable("id") Long id){
        return prefectureService.findDetail(id,PrefectureDetailDTO.class);
    }

    /**
     * <h2>新增专区表详情</h2>
     * @param prefectureBO {@link PrefectureBO} 专区表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增专区表",notes = "新增专区表")
    @PostMapping(value = "/addPrefecture")
    public RespJson addPrefecture(@RequestBody PrefectureBO prefectureBO){
        return prefectureService.addPrefecture(prefectureBO);
    }

    /**
     * <h2>修改专区表详情</h2>
     * @param prefectureBO  {@link PrefectureBO} 专区表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改专区表",notes = "修改专区表")
    @PostMapping(value = "/editPrefecture")
    public RespJson editPrefecture(@RequestBody PrefectureBO prefectureBO){
        return prefectureService.editPrefecture(prefectureBO);
    }

    /**
     * <h2>根据主键编号删除专区表信息</h2>
     * @param id  专区表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除专区表",notes = "根据地址ID，删除专区表")
    @PostMapping(value = "/deletePrefecture/{id}")
    public RespJson deletePrefecture(@PathVariable("id") Long id){
        return prefectureService.deletePrefecture(id);
    }

    /**
     * <h2>校验专区名称是否存在</h2>
     * @param prefectureName  专区名称
     * @return
     */
    @ApiOperation(value = "校验专区名称是否存在",notes = "校验专区名称是否存在")
    @PostMapping(value = "/validataPrefectureNameExist/{prefectureName}")
    public RespJson validataPrefectureNameExist(@PathVariable("prefectureName") String prefectureName){
        return prefectureService.validataPrefectureNameExist(prefectureName);
    }

    /**
     * <h2>修改专区状态</h2>
     * @param prefectureStatusBO 专区状态请求对象
     * @return
     */
    @PostMapping(value = "/modifyPrefectureStatus")
    public RespJson modifyPrefectureStatus(@RequestBody PrefectureStatusBO prefectureStatusBO){
        return prefectureService.modifyPrefectureStatus(prefectureStatusBO);
    }

    /**
     * <h2>查找专区商品表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<PrefectureGoodsListDTO> {@link PrefectureGoodsListDTO}s  专区商品表 列表返回对象
     */
    @ApiOperation(value = "查询专区商品表列表" ,notes = "查询专区商品表列表")
    @GetMapping(value = "/findPrefectureGoodsList")
    public RespJsonPageData<PrefectureGoodsListDTO> findPrefectureGoodsList(@RequestParam  Map<String,Object> params){
        return prefectureGoodsService.findPrefectureGoodsList(params);
    }

    /**
     * <h1>修改专区商品推荐状态</h1>
     * @param prefectureGoodsStatusBO
     * @return
     */
    @ApiOperation(value = "修改专区商品推荐状态" ,notes = "修改专区商品推荐状态")
    @PostMapping(value = "/modifyPrefectureGoodsStatus")
    public RespJson modifyPrefectureGoodsStatus(@RequestBody PrefectureGoodsStatusBO prefectureGoodsStatusBO){
        return prefectureGoodsService.modifyPrefectureGoodsStatus(prefectureGoodsStatusBO);
    }

    /**
     * <h2>根据主键编号删除专区商品表信息</h2>
     * @param id  专区商品表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除专区商品表",notes = "根据地址ID，删除专区商品表")
    @PostMapping(value = "/deletePrefectureGoods/{id}")
    public RespJson deletePrefectureGoods(@PathVariable("id") Long id){
        return prefectureGoodsService.deletePrefectureGoods(id);
    }

    /**
     * <h2>新增专区商品表详情</h2>
     * @param prefectureGoodsBO {@link PrefectureGoodsBO} 专区商品表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增专区商品表",notes = "新增专区商品表")
    @PostMapping(value = "/addPrefectureGoods")
    public RespJson addPrefectureGoods(@RequestBody PrefectureGoodsBO prefectureGoodsBO){
        return prefectureGoodsService.addPrefectureGoods(prefectureGoodsBO);
    }

    /**
     *
     * @param prefectureGoodsListBO
     * @return
     */
    @GetMapping(value = "/findGoodsSkuAll")
    public RespJsonData<List<GoodsSkuListDTO>> findGoodsSkuAll(PrefectureGoodsListBO prefectureGoodsListBO){
        return prefectureGoodsService.findGoodsSkuAll(prefectureGoodsListBO);
    }
}

